"""
    请求库： requests
    解析工具： bs4
"""
import requests
import random

url = 'https://v.douyin.com/UEEwapL/'

headers = {
    "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1",
    "Cookie": 'ttwid=1%7CNJtFy5VR8ubp9ZO3NPim4N2P9Fe6eliT-5hzFTnSWuQ%7C1683821103%7Cae709ae6c4620626186590afa7732e93edc89b7bfc33fa7704d330fc1ecc4a2b; ',
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
    "Sec-Fetch-Dest":
        "document",
    "Sec-Fetch-Mode":
        "navigate",
    "Sec-Fetch-Site":
        "none",
    "Sec-Fetch-User":
        "?1",
    "Upgrade-Insecure-Requests":
        "1",
    "Authority":"v.douyin.com",
    "Path":"/UEEwapL/",
    "Scheme":"https"
}

response = requests.get(url, headers=headers)
print(response.headers)

'https://m.douyin.com/aweme/v1/playwm/?video_id=vOdOOfg10000chnjj4rc77u2l2gig6kg&ratio=720&line=0'


def generate_random_str(self, randomlength=107):
    """
    根据传入长度产生随机字符串
    """
    random_str = ''
    base_str = 'ABCDEFGHIGKLMNOPQRSTUVWXYZabcdefghigklmnopqrstuvwxyz0123456789='
    length = len(base_str) - 1
    for _ in range(randomlength):
        random_str += base_str[random.randint(0, length)]
    return random_str